{  Statement: http://acmp.ru/?main=task&id_task=65
   Verdict: Accepted
}
uses
    SysUtils, Math;

var
    i, j, ls, cur, cm, ans, n : longint;
    a : array[0..70000] of longint;
    s, t : string;
    
begin
    reset(input,'input.txt');
    rewrite(output,'output.txt');
    readln(s);
    ls := length(S);
    readln(n);
    cm := maxlongint;
    ans := 0;
    for i := 1 to n do begin
        readln(t);
        cur := 0;
        for j := 1 to ls do
            inc(cur, byte(s[j] <> t[j]));
        if cur < cm then begin
            cm := cur;
            ans := 1;
            a[1] := i;
        end else
        if cur = cm then begin
            inc(ans);
            a[ans] := i;
        end;
    end;
    writeln(ans);
    for i := 1 to ans do
        write(a[i], ' ');
end.
